/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Utility;

/**
 *
 * @author Nhan Nguyen
 */

public class Helper {

    public static void fillCharArray(char arr[], char value) {
        for (int i=0; i<arr.length; i++) {
            arr[i] = value;
        }
    }

    public static String prepad(String s, int length, char c) {
        int needed = length - s.length();
        if (needed <= 0) {
            return s;
        }
        char padding[] = new char[needed];
        fillCharArray(padding, c);
        StringBuffer sb = new StringBuffer(length);
        sb.append(padding);
        sb.append(s);
        return sb.toString();
    }

    public static String intToStrWithZero(int i, int length) {
        return prepad(String.valueOf(i), length, '0');
    }
}
